<!-- 风控-企业预警- 服务到期 -->
<template>
  <div>
    <Details ref="details" @ok="search"></Details>
    <Ignore ref="ignore" @ok="search"></Ignore>
    <ServiceExtension ref="serviceExtension" @ok="search"></ServiceExtension>
    <ZgNewPage
      ref="page"
      :title="pageTitle"
      :showInlineBtn="false"
      :uniqueName="uniqueName"
      :pageOpt="pageOpt"
      :dataBtns="dataBtns"
      :headers="headers"
      :conditions="conditions"
      :adminWidth="350"
      @search="onSearch"
      @filter="onFilter"
      @header="mergeHeader"
      @admin="toAdmin"
    >
      <template slot="columns">
        <a-table-column
          v-for="(h,i) in headers"
          :key="`column${i}`"
          :width="h.width===0 ? 'auto' : h.width"
          align="center"
          :title="h.label">
          <template slot-scope="record">
            <template>{{ record[h.code] }}</template>
          </template>
        </a-table-column>
      </template>
      <template slot="thMode" slot-scope="scope">
        <a-row :gutter="10">
          <a-col :span="4" v-for="t in scope.list" :key="`thMode_${t.id}`">
            <a-card class="mb10">
              <div class="wfull h100 scroll">
                {{ t }}
              </div>
            </a-card>
          </a-col>
        </a-row>
      </template>
    </ZgNewPage>
  </div>
</template>
<script>
import Ignore from './Ignore'
import ServiceExtension from './ServiceExtension'
import Details from './Details'

const list = [
    { value: '1', label: '1' },
    { value: '2', label: '2' },
    { value: '3', label: '3' }
]
export default {
   components: {
       Ignore, ServiceExtension, Details
  },
  data () {
    return {
      pageTitle: '金融机构管理',
      uniqueName: 'test',
      A: {
        '1': '暂存',
        '2': '待审核',
        '3': '已融资',
        '4': '已驳回',
        '5': '已作废',
        '6': '审核中'
      },
      pageOpt: {
        showConditionBtn: true,
        showHeaderConfig: true,
        showAttachBtn: true,
        showPageTitle: false
      },
      conditions: [
        { code: 'code', compType: '单行文本', label: '公司名称', defaultVal: '' },
        { code: 'select', compType: '下拉选择', label: '企业类型', defaultVal: '', extra: { 下拉选项: list } }
      ],
      headers: [
        { code: 'A', label: '企业名称', isShow: true, sort: 0 },
        { code: 'B', label: '企业类型', isShow: true, sort: 0 },
        { code: 'C', label: '服务到期时间', isShow: true, sort: 0 },
        { code: 'D', label: '预警内容', isShow: true, sort: 0 },
        { code: 'E', label: '预警时间', isShow: true, sort: 0 },
        { code: 'F', label: '处理时间', isShow: true, sort: 0 },
        { code: 'G', label: '处理结果', isShow: true, sort: 0 }
      ],
      dataBtns: [
        { key: 1, name: '详情', type: 'link', isShow: () => { return true } },
        { key: 2, name: '服务延期', type: 'link', isShow: () => { return true } },
        { key: 3, name: '企业注销', type: 'link', isShow: () => { return true } },
        { key: 4, name: '忽略', type: 'link', isShow: () => { return true } }
      ]
    }
  },
  methods: {
    search () {
      this.$refs.page.search()
    },
    onSearch (param) {
      const diyHeaders = localStorage.getItem(this.currentUser.username + '_diyHeader_' + this.uniqueName)
      if (diyHeaders) {
        this.mergeHeader(JSON.parse(diyHeaders))
      }
      // 加载表头
      const list = [
        { key: '1', id: '1', A: '2025611', B: '2025611', C: '产品授信', D: '浦发银承贷款', E: '100.000.00', F: '90.000.00', G: '2025-6-11 16：08', H: '李华', isUse: true },
        { key: '2', id: '2', A: '2025611', B: '2025611', C: '产品授信', D: '浦发银承贷款', E: '100.000.00', F: '90.000.00', G: '2025-6-11 16：08', H: '李华', isUse: true },
        { key: '3', id: '3', A: '2025611', B: '2025611', C: '产品授信', D: '浦发银承贷款', E: '100.000.00', F: '90.000.00', G: '2025-6-11 16：08', H: '李华', isUse: true }
      ]
      this.$refs.page.endSearch({
        total: list.length,
        list: list
      })
    },
    onFilter (f, param) {
    },
    toAdmin (param) {
      if (param.key === 1) {
        this.$refs.details.open()
      } else if (param.key === 2) {
        this.$refs.serviceExtension.open()
      } else if (param.key === 3) {
         alert('企业注销')
      } else if (param.key === 4) {
        this.$refs.ignore.open()
      }
    },
    toExtra (opt) {
      if (opt.key === 1) {
        alert('导出')
      } else {
        alert('申请')
      }
    },
    mergeHeader (newHeaders) {
      if (!newHeaders) {
        return
      }
      this.headers = newHeaders.filter(t => {
        return t.isShow
      }).sort((a, b) => {
        return a.sort - b.sort
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
